;
(function() {
	var skill = {
		_bindTicket: function(ticket_id) {
			if (!this.changeAble()) {
				throwCusError("订单已确认，不能在绑定优惠券")
			}
			if (this.use_tickets && this.use_tickets.length) {
				throwCusError("订单已经绑定优惠券，不可修改")
			}
			var ticket = TicketCon.get(ticket_id);
			if (!ticket) {
				throwCusError("找不到指定优惠券")
			}
			if (!ticket._canUseForAch(this)) {
				throwCusError("该优惠券无法在当前店铺使用")
			}
			var buff = ticket.toBuff();
			console.log(buff);
			this._addBuffByInstance(buff);
			//标记为已使用
			ticket._useForAch(this._id);
			//绑定后就不能修改了
			this.ticket_id = ticket_id;
			// (this.use_tickets || (this.use_tickets = [])).push(ticket_id);
			this.save();
		}
	};
	module.exports = skill;
	var db = require("../db/index");
	var TicketCon = require("../ticket/_con");
	var GoodsCon = require("../goods/_con");
	var UserCon = require("../../core/user/_con");
	var BusCon = require("../../core/bus/_con");
	var AchCon = require("../ach/_con");
	var ClassifyCon = require("../bus.classify/_con");
	var TagCon = require("../bus.tag/_con");
	var LeagueCon = require("../league/_con");
	var BuffCon = require("../buff/_con");
	var BusUserBindCon = require("../bus_user_bind/_con");
	var BusGuideCon = require("../bus.guide/_con");
	var CommentCon = require("../comment/_con");
	var config = require("../_include/config");
	var data_cut = require("../_include/data_cut");
	var helper = require("../_include/helper");
	var md5 = require("../_include/md5");
	var $Object = require("../_include/$.Object");
	var $Array = require("../_include/$.Array");
}());